<div class="main-content">
	<!-- #section:basics/content.breadcrumbs -->
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb"><li>
			<i class="ace-icon fa fa-th-large th-large-icon"></i> cms管理 <i class="ace-icon fa fa-angle-double-right"></i> <?=isset($kid)?'修改':'添加'?>文章 
		</li></ul><!-- /.breadcrumb -->
	</div>

	<!-- /section:basics/content.breadcrumbs -->
	<div class="page-content">
		<!-- #section:settings.box -->
		<div class="ace-settings-container" id="ace-settings-container" style="margin-top:-48px;">
			<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
				<i class="ace-icon fa fa-cog bigger-150"></i>
			</div>
			<div class="ace-settings-box clearfix" id="ace-settings-box">
				<div class="pull-left width-50">
					<!-- #section:settings.skins -->
					<div class="ace-settings-item">
						<div class="pull-left">
							<select id="skin-colorpicker" class="hide">
								<option data-skin="no-skin" value="#438EB9" <?=!isset($_COOKIE['ace_skin'])||$_COOKIE['ace_skin']!='no-skin'?'selected':''?> >#438EB9</option>
								<option data-skin="skin-1" value="#222A2D" <?=isset($_COOKIE['ace_skin'])&&$_COOKIE['ace_skin']=='skin-1'?'selected':''?> >#222A2D</option>
								<option data-skin="skin-2" value="#C6487E" <?=isset($_COOKIE['ace_skin'])&&$_COOKIE['ace_skin']=='skin-2'?'selected':''?> >#C6487E</option>
								<option data-skin="skin-3" value="#D0D0D0" <?=isset($_COOKIE['ace_skin'])&&$_COOKIE['ace_skin']=='skin-3'?'selected':''?> >#D0D0D0</option>
							</select>
						</div>
						<span>&nbsp;肤色切换</span>
					</div>

					<!-- /section:settings.skins -->

					<!-- #section:settings.navbar -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
						<label class="lbl" for="ace-settings-navbar">&nbsp; 固定导航</label>
					</div>

					<!-- /section:settings.navbar -->

					<!-- #section:settings.sidebar -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
						<label class="lbl" for="ace-settings-sidebar">&nbsp; 固定菜单栏</label>
					</div>
					<!-- /section:settings.sidebar -->
					
					<!-- #section:settings.container -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
						<label class="lbl" for="ace-settings-add-container">&nbsp; 宽窄屏切换</label>
					</div>
					<!-- /section:settings.container -->
				</div><!-- /.pull-left -->

				<div class="pull-left width-50">
					<!-- #section:basics/sidebar.options -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-hover" />
						<label class="lbl" for="ace-settings-hover">&nbsp; 内级栏目切换</label>
					</div>

					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-compact" />
						<label class="lbl" for="ace-settings-compact">&nbsp; 菜单栏切换</label>
					</div>

					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-highlight" />
						<label class="lbl" for="ace-settings-highlight">&nbsp; 当前菜单凸显</label>
					</div>
					<!-- /section:basics/sidebar.options -->
				</div><!-- /.pull-left -->
			</div><!-- /.ace-settings-box -->
		</div><!-- /.ace-settings-container -->

		<!-- /section:settings.box -->
		<div class="page-content-area">
			<div class="row">
				<div class="col-xs-12">
					<script charset="utf-8" src="/public/sysadmin/kindeditor-4.1.10/kindeditor-min.js"></script>
					<script charset="utf-8" src="/public/sysadmin/kindeditor-4.1.10/lang/zh_CN.js"></script>
					<script charset="utf-8" src="/public/sysadmin/kindeditor-4.1.10/php/upload_json.php"></script>
					<script>
						var editor;
						KindEditor.ready(function(K) {
							editor = K.create('textarea[name="contentTxet"]', {
									allowFileManager : true,
									afterBlur: function(){this.sync();}
							});
						}); 
					</script>
					<link rel="stylesheet" href="/public/assets/css/datepicker.css" />
					<script src="/public/assets/js/date-time/bootstrap-datepicker.min.js"></script>
					<script src="/public/assets/js/date-time/daterangepicker.min.js"></script>
					<script src="/public/assets/js/date-time/moment.min.js"></script>
					<script src="/public/assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js"></script>
					<script src="/public/assets/upload/jquery.uploadify.min.js"></script>
					<style>
						table{width:100%;}
						table tr td{padding:5px 0;}
						table tr td input,table tr td select,table tr td textarea{width:300px;}
						table tr td label{width:70px;}
						.upload{
							width: 300px;height: 150px;border:1px solid #ddd;float:left;
							background: url("/public/home/img/to/upload.png") no-repeat center;
						}
						#data_avator,#data_avator_2{width: 100%;background: none;opacity: 0;filter:alpha(opacity=0)}
						.upload .show_img{width: 100%;height: 150px;z-index:1;display:block;margin-top:-150px;text-align:center;}
						.upload .close{
							width: 30px;height: 30px;background: url("/public/home/img/to/default.png") -33px 0 no-repeat;
							display: block;right: 0px;z-index: 2;margin-top:-150px;
						}
					</style>
					<table>
						<tr><td style="padding:0 0 20px 70px;">
							<button type="button" class="btn btn-sm gobanck" data-toggle="button">返回</button>
						</td></tr>
						<form action="" method="post" id="fmUP">
							<input type="hidden" name="kid" value="<?=isset($kid)?$kid:''?>" />
							<tr><td><label>标题</label><input type="text" name="title" value="<?=isset($result)?$result['title']:''?>"></td></tr>
							<tr><td><label>类别</label><select name="modelid">
									<option value="0">请选择</option>
									<?foreach($model as $k=>$v){?><option value="<?=$v['id']?>" <?=isset($result)&&$result['modelid']==$v['id']?'selected':''?>><?=$v['title']?></option><?}?>
							</select></td></tr>
							<tr><td><label style="float:left;">封面</label>
								<div class="upload data_avator_1">
									<input type="hidden" name="imgurl" value="<?=isset($result)?$result['imgurl']:''?>">
									<input type="file" id="data_avator" class="file1" style="width:100%;height:150px;" />
									<img src="<?=isset($result)?$result['imgurl']:''?>" class="show_img" <?=isset($result)?'':'style="display:none;"'?>/>
									<a href="javascript:;" title="删除" data-rel="tooltip" class="close"></a>
								</div>
							</td></tr>
							<tr><td><label style="float:left;">文档</label>
								<div class="upload data_avator_2">
									<input type="hidden" name="texturl" value="<?=isset($result)?$result['texturl']:''?>">
									<input type="file" id="data_avator_2" class="file2" style="width:100%;height:130px;" />
									<div class="show_img" style="<?=isset($result)?'':'display:none;'?>background:#fff;border-bottom:1px solid #ddd;line-height:150px;"><?=isset($result)?$result['texturl']:''?></div>
									<a href="javascript:;" title="删除" data-rel="tooltip" class="close close_3"></a>
								</div>
							</td></tr>
							<tr><td><label style="display:inline-block;margin-top:-120px;">简介</label>
								<textarea name="briefing" rows="3" style="resize:none;"><?=isset($result)?$result['briefing']:''?></textarea>
							</td></tr>
							<tr><td><label style="display:block;float:left;">内容</label>
								<textarea name="contentTxet" style="height: 300px;"><?=isset($result)?$result['contentTxet']:''?></textarea>
							</td></tr>
							<tr><td><label>状态</label>
								<label><input name="status" type="radio" value="1" class="ace" <?=isset($result)&&$result['status']==1?'checked':''?>><span class="lbl"> 正常</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<label><input name="status" type="radio" value="2" class="ace" <?=isset($result)?($result['status']==2?'checked':''):'checked'?>><span class="lbl"> 禁用</span></label>
							</td></tr>
							<tr><td><label>时间</label><input type="text" class="date-picker" name="ktime" value="<?=isset($result)?$result['ktime']:''?>" readonly ></td></tr>
						</form>
						<tr><td style="padding:20px 0 0 70px;">
							<button type="button" class="btn btn-sm gobanck" data-toggle="button">返回</button>
							<button type="button" class="btn btn-sm btn-info confirm" data-toggle="button">提交</button>
						</td></tr>
					</table>
				</div><!-- /.col -->
			</div><!-- /.row -->
		</div><!-- /.page-content-area -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
<!-- inline scripts related to this page -->

<script type="text/javascript">
$('.date-picker').datepicker({
	autoclose:true,
	format:'yyyy-mm-dd',
	language:"zh-CN",
	todayBtn:true,
	todayHighlight:true,
	startDate:''
});
$('table .gobanck').click(function(){
	var url="";
	if(Number($('input[name=kid]').val())<1){
		url=$('input[name="imgurl"]').val()+'@'+$('input[name="texturl"]').val()
	}
	$.ajax({
		type:'POST',
		url:'<?=$this->url("cms/urlSet")?>',
		data:'url='+url,
		dataType:'json',
		success:function(r){}
	});
	$('table tr td input[type="hidden"]').val('');
	window.history.go(-1);
})
$(".upload .close").click(function(){
	$.ajax({
		type:'POST',
		url:'<?=$this->url("cms/urlSet")?>',
		data:'url='+$(this).parent().find('input[type="hidden"]').val(),
		dataType:'json',
		success:function(r){}
	});
	$(this).parent().find('input[type="hidden"]').val('')
	$(this).parent().find('img.show_img').attr('src','').hide();
	$(this).parent().find('div.show_img').html('').hide();
});
$('.data_avator_1 .file1').uploadify({
	'formData'     : {
		'timestamp' : '<?=time()?>',
		'token'     : '<?=md5('unique_salt' . time())?>'
	},
	'swf': '/public/assets/upload/uploadify.swf',
	'fileType': 'image/*',
	'fileObjName':'pic',
	'height':'150',
	'width':'300',
	'left': '0',
	'queueID':'data_avator_1',
	'buttonClass':'uploadSwf1',
	'uploader' : '/upload.php?tle=0',
	'onUploadSuccess' : function(file, data, response) {
		data= eval('(' + data + ')');
		if(data.state==1){
			$(".data_avator_1").find(".show_img").attr('src',data.logo);
			$("input[name='imgurl']").val(data.logo);
			$(".data_avator_1").find(".show_img").show();
		}else{
			gritter("gritter-error gritter-light",3000,"操作提示",data.html);
		}
	}
});
$('.data_avator_2 .file2').uploadify({
	'formData'     : {
		'timestamp' : '<?=time()?>',
		'token'     : '<?=md5('unique_salt' . time())?>'
	},
	'swf': '/public/assets/upload/uploadify.swf',
	'fileType': 'image/*',
	'fileObjName':'pic',
	'height':'150',
	'width':'300',
	'left': '0',
	'queueID':'data_avator_2',
	'buttonClass':'uploadSwf1',
	'uploader' : '/upload.php?tle=1',
	'onUploadSuccess' : function(file, data, response) {
		data= eval('(' + data + ')');
		if(data.state==1){
			$(".data_avator_2").find(".show_img").html(data.fileName);
			$("input[name='texturl']").val(data.logo);
			$(".data_avator_2").find(".show_img").show();
		}else{
			gritter("gritter-error gritter-light",3000,"操作提示",data.html);
		}
	}
});
$('table .confirm').click(function(){
	$.ajax({
		type:'POST',
		url:'<?=$this->url("cms/infoEdit")?>',
		data:$('#fmUP').serialize(),
		dataType:'json',
		success:function(r){
			if(r.state==1){
				gritter("gritter-success gritter-light",3000,"操作提示",r.html);
				setTimeout('window.location.href="<?=$this->url('cms/info')?>"',3000);
			}else{
				gritter("gritter-error gritter-light",3000,"操作提示",r.html);
			}
		},
		error:function(){
			gritter("gritter-error gritter-light",3000,"操作提示","网络错误！请联系我方工作人员。");
		}
	});
})
</script>